﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;


namespace DBContest
{
    public static class ExcelUtilities
    {
        private static string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;""";

        public static void ReadFromFile(string filePath)
        {
            string connectionStr = string.Format(ConnectionString, filePath);
            OleDbConnection connection = new OleDbConnection(connectionStr);

            DataSet salesReport = new DataSet();
            using (connection)
            {
                OleDbCommand comm = new OleDbCommand("Select * FROM [Sales$]", connection);

                OleDbDataAdapter adapter = new OleDbDataAdapter();
                adapter.SelectCommand = comm;
               // connection.Open();
                adapter.Fill(salesReport);

            }

            DataTableReader reader = salesReport.CreateDataReader();
            using (reader)
            {
                while (reader.Read())
                {
                   
                }
            }
                
            
        }
    }
}
